/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package consistency_check.beans;

import consistency_check.business.ConsistencyCheckBusiness;
import consistency_check.business.ConsistencyCheckResult;
import data_bases.DAO.DatabaseDAO;
import data_bases.beans.TableBean;
import data_bases.business.DataBaseBusiness;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

/**
 *
 * @author Javier
 */
@ManagedBean
@RequestScoped
public class consistenceCheckBean {
    private List<ConsistencyCheckResult> result;
    private String database;
    private String schema;
    private List<String> schemas;
    
    public String getDatabase() {
        return database;
    }

    public String getSchema() {
        return schema;
    }

    public void setSchema(String schema) {
        this.schema = schema;
    }

    public List<String> getSchemas() {
        return schemas;
    }

    public void setSchemas(List<String> schemas) {
        this.schemas = schemas;
    }

    public void setDatabase(String database) {
        this.database = database;
    }
    public consistenceCheckBean(){
         try {
            schemas = new DataBaseBusiness(new DatabaseDAO().viewDatabases()).getSchemasString();
        } catch (SQLException ex) {
            Logger.getLogger(TableBean.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void reloadTable(){
        if(!schema.equals(""))
            result = new ConsistencyCheckBusiness().checkAllDatabase(schema);
    }
    
    public List<ConsistencyCheckResult> getResult() {
        return result;
    }
}
